﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AcctrueWMS.Foundation.Web;
using AcctrueWMS.Foundation.Data;
using System.Data;
using AcctrueWMS.Foundation.DAL;
namespace AcctruePMS.Bll.Manager
{

    /// <summary>
    /// 行业线管理
    /// </summary>
     public class IndustryLineManager
    {
         /// <summary>
         /// 获取行业线的负责人编号，拼成字符串，以","号分隔
         /// </summary>
         /// <param name="industryLineCode">行业线编码</param>
        /// <param name="noOrName">行业线负责人的编号还是名称</param>
         /// <returns></returns>
         public string GetPrincipalString(string industryLineCode,string noOrName) {
             string sql = "";
             switch (noOrName)
             {
                 case "no":
                     sql = "select userNo as [value] from industryLinePrincipal where industryLineCode=@industryLineCode";
                     break;
                 case "name":
                     sql = "select userInfo.displayName as [value] from industryLinePrincipal as ilp inner join userInfo on userInfo.userNo=ilp.userNo where ilp.industryLineCode=@industryLineCode ";
                     break;
                 default:
                     return "";
             }
             IDataParameter[] pars = { DBFactory.NewParameter("@industryLineCode", industryLineCode) };
             DataTable dt = WMSqlExcuter.ExecuteRealDataTable(sql,pars);
             StringBuilder principals = new StringBuilder();//负责人
             foreach (DataRow row in dt.Rows)
             {
                 principals.Append(row["value"]);
                 principals.Append(",");
             }
             string pS=principals.ToString();
             if (pS.Length == 0) return "";
             return pS.Substring(0, pS.Length-1);
         }

    }
}
